package com.neu.dao.impl;

import com.neu.dao.BaseDao;
import com.neu.dao.MemberDao;

import java.util.List;
import java.util.Map;

public class MemberDaoImpl extends BaseDao implements MemberDao {
    @Override
    public Map<String, Object> login(String name, String pwd) {
        Map<String,Object> map =null;
        String sql="select * from tbl_member where member_name=? and member_pwd=MD5(?)" ;
        List<Map<String,Object>> list = super.executeQuery(sql,name,pwd);
        if (list.size()>0){
            map =list.get(0);
        }
        return map;
    }

    @Override
    public int insertMember(String name) {
        int row =0;
        String sql="insert into tbl_member(member_pwd,member_name)\n" +
                "\tVALUES(MD5('888888'),?)";
        row = super.executeUpdate(sql,name);
        return row;
    }

    @Override
    public int deleteMember(String name) {
        int row=0;
        String sql ="update tbl_member set member_exist =0 where member_name =?";
        row=super.executeUpdate(sql,name);
        return row;
    }

    @Override
    public List<Map<String, Object>> findAll() {
        List<Map<String,Object>> list =null;
        String sql="select member_id,member_name\n" +
                " from tbl_member" +
                " where member_status='1'";
        list = super.executeQuery(sql);
        return list;
}
}
